package com.wlyuan.open.scanner.application.handler.full;

import com.wlyuan.open.dto.OpenOrderSyncDTO;
import com.wlyuan.open.scanner.application.annotation.ScannerCode;
import com.wlyuan.open.scanner.assembler.ScannerOrderAssembler;
import com.wlyuan.open.scanner.constant.ScannerCodeEnum;
import com.wlyuan.open.scanner.domain.order.Order;
import com.wlyuan.open.scanner.repository.OrderRepository;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author lijing
 * @description
 */
@ScannerCode(code = ScannerCodeEnum.ORDER)
@Service
@Slf4j
@RequiredArgsConstructor
public class ScannerOrderHandler extends BaseScannerHandler<Order, OpenOrderSyncDTO> {
    private final OrderRepository orderRepository;

    @Override
    protected List<Order> select() {
        return orderRepository.list();
    }

    @Override
    protected List<OpenOrderSyncDTO> assembler(List<Order> data) {
        return ScannerOrderAssembler.assemble(data);
    }
}
